<script>
    import { onMount } from 'svelte'
    import {location, querystring} from 'svelte-spa-router'
    import Detail from '../components/detail.svelte';

    import { Post } from '../lib/net.js';
    import { PlatformAssetsDetail } from '../api.js';

    let data = {list:[]};
    let map_type = ["充值", "提币", "划转", "划转", "盈利",  "赔付" ];
    let map_state = ["待审核","进行中","已完成","已取消"];
    
    onMount(async ()=>{
       let tid = $querystring.replace("tid=","");
       let ret = await Post(PlatformAssetsDetail,{tid});

       let symbol = "";
       if(ret.type == 0 || ret.type == 4) {
        data.color = "green"
        symbol = "+";
       }
       if(ret.type == 1 || ret.type == 5) {
        data.color = "red"
        symbol = "-";
       }

       data.title = map_type[ret.type];
       data.subtitle = symbol + " " + ret.amount;
       data.list = [
        {key: "提现地址",val: ret.withdraw_addr},
        {key: "操作时间",val: ret.show_operate_date},
        {key: "操作编号",val: ret.tid},
        {key: "交易状态",val: map_state[ret.state]}
       ]
    });

</script>

<Detail data={data}/>    

<style>

</style>
